#include <string.h>
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{

	int fd;
	void* addr;
	int i= 0;;

	fd = open("test", O_RDWR);
	if(fd < 0)
	{
		perror("open");
	}

	//创建共享内存
	addr = mmap(NULL, 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	if(addr == MAP_FAILED)
	{
		perror("mmap");

	}

	while( i < 1024)
	{
		memcpy((addr+i), "a", 1);
		i++;
		sleep(1);

	}


}












